﻿<?xml version="1.0" encoding="utf-8"?>
<!--
        作者：          leyi.liu
        更新时间：      20150923
        用途：          生成应用服务器的初始化数据
        修改历史：			by jun.wu at 20151112 支持Price类型 
-->
<xsl:stylesheet version="2.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:xs="http://www.w3.org/2001/XMLSchema"
	xmlns:fn="http://www.w3.org/2005/xpath-functions">
	<xsl:output method="text" indent="no" encoding="utf-8" byte-order-mark="no"/>  
	<xsl:template match="/">
	<xsl:variable name="MetadataTypeDefine" select="document('../model/0101_metadataTypeDefine.xml')"/>
	<xsl:variable name="FunctionsPD" select="document('../model/0201_FunctionsTD.xml')"/>
	<xsl:variable name="FunctionsHS" select="document('../model/0202_FunctionsHS.xml')"/>
	<xsl:result-document encoding="utf-8" method="text" href="./generate/sql/InitData/function_init.sql">
delete t_mc_function;
delete t_mc_function_detail;
  <xsl:for-each select="$FunctionsPD/Functions/Function">
  <xsl:variable name="FuncNo" select="@func_no"/>
  <xsl:variable name="Resonse" select="count(Response)"/>
insert into t_mc_function(FunctionNo,DataBaseDeployType,IsOpenCursor,FunctionDesc,IsSettleLock,FuncType,UpdateOperID,UpdateDate,UpdateTime)values
('<xsl:value-of select="$FuncNo"/>','0','<xsl:value-of select="$Resonse"/>','<xsl:value-of select="@func_name"/>',nvl('<xsl:value-of select="@IsSettleLock"/>','0'),nvl('<xsl:value-of select="@FuncType"/>','0'),'SYS',to_char(sysdate,'YYYYMMDD'),to_char(sysdate,'HH24:MI:SS'));
<xsl:for-each select="Request/Field">
<xsl:variable name="Name" select="@name"/>
insert into t_mc_function_detail(FunctionNo,FuncParaType,FuncParaIndex,FuncParaCode,FuncParaDataType,FuncParaDataLength,UpdateOperID,UpdateDate,UpdateTime)values
('<xsl:value-of select="$FuncNo"/>','0','<xsl:value-of select="position()"/>','<xsl:value-of select="$Name"/>',<xsl:for-each select="$MetadataTypeDefine//String[@typename=$Name]"> 'DB_COLOUMN_TYPE_CHAR',<xsl:value-of select="@length"/></xsl:for-each><xsl:for-each select="$MetadataTypeDefine//Money[@typename=$Name]">'DB_COLOUMN_TYPE_DOUBLE',NULL</xsl:for-each><xsl:for-each select="$MetadataTypeDefine//Price[@typename=$Name]">'DB_COLOUMN_TYPE_DOUBLE',NULL</xsl:for-each><xsl:for-each select="$MetadataTypeDefine//Ratio[@typename=$Name]">'DB_COLOUMN_TYPE_DOUBLE',NULL</xsl:for-each><xsl:for-each select="$MetadataTypeDefine//Long[@typename=$Name]">'DB_COLOUMN_TYPE_INT',NULL</xsl:for-each><xsl:for-each select="$MetadataTypeDefine//Enum[@typename=$Name]"> 'DB_COLOUMN_TYPE_CHAR',2</xsl:for-each><xsl:for-each select="$MetadataTypeDefine//Boolean[@typename=$Name]">'DB_COLOUMN_TYPE_CHAR',1</xsl:for-each>,'v8s',to_char(sysdate,'YYYYMMDD'),to_char(sysdate,'HH24:MI:SS'));
</xsl:for-each>
<xsl:for-each select="Response/Field">
<xsl:variable name="Name" select="@name"/>
insert into t_mc_function_detail(FunctionNo,FuncParaType,FuncParaIndex,FuncParaCode,FuncParaDataType,FuncParaDataLength,UpdateOperID,UpdateDate,UpdateTime)values
('<xsl:value-of select="$FuncNo"/>','1','<xsl:value-of select="position()"/>','<xsl:value-of select="$Name"/>',<xsl:for-each select="$MetadataTypeDefine//String[@typename=$Name]"> 'DB_COLOUMN_TYPE_CHAR',<xsl:value-of select="@length"/></xsl:for-each><xsl:for-each select="$MetadataTypeDefine//Money[@typename=$Name]">'DB_COLOUMN_TYPE_DOUBLE',NULL</xsl:for-each><xsl:for-each select="$MetadataTypeDefine//Price[@typename=$Name]">'DB_COLOUMN_TYPE_DOUBLE',NULL</xsl:for-each><xsl:for-each select="$MetadataTypeDefine//Ratio[@typename=$Name]">'DB_COLOUMN_TYPE_DOUBLE',NULL</xsl:for-each><xsl:for-each select="$MetadataTypeDefine//Long[@typename=$Name]">'DB_COLOUMN_TYPE_INT',NULL</xsl:for-each><xsl:for-each select="$MetadataTypeDefine//Enum[@typename=$Name]"> 'DB_COLOUMN_TYPE_CHAR',2</xsl:for-each><xsl:for-each select="$MetadataTypeDefine//Boolean[@typename=$Name]">'DB_COLOUMN_TYPE_CHAR',1</xsl:for-each>,'v8s',to_char(sysdate,'YYYYMMDD'),to_char(sysdate,'HH24:MI:SS'));
 </xsl:for-each>
 </xsl:for-each>
  <xsl:for-each select="$FunctionsHS/Functions/Function">
  <xsl:variable name="FuncNo" select="@func_no"/>
  <xsl:variable name="Resonse" select="count(Response)"/>
insert into t_mc_function(FunctionNo,DataBaseDeployType,IsOpenCursor,FunctionDesc,IsSettleLock,FuncType,UpdateOperID,UpdateDate,UpdateTime)values
('<xsl:value-of select="$FuncNo"/>','1','<xsl:value-of select="$Resonse"/>','<xsl:value-of select="@func_name"/>',nvl('<xsl:value-of select="@IsSettleLock"/>','0'),nvl('<xsl:value-of select="@FuncType"/>','0'),'SYS',to_char(sysdate,'YYYYMMDD'),to_char(sysdate,'HH24:MI:SS'));
<xsl:for-each select="Request/Field">
<xsl:variable name="Name" select="@name"/>
insert into t_mc_function_detail(FunctionNo,FuncParaType,FuncParaIndex,FuncParaCode,FuncParaDataType,FuncParaDataLength,UpdateOperID,UpdateDate,UpdateTime)values
('<xsl:value-of select="$FuncNo"/>','0','<xsl:value-of select="position()"/>','<xsl:value-of select="$Name"/>',<xsl:for-each select="$MetadataTypeDefine//String[@typename=$Name]"> 'DB_COLOUMN_TYPE_CHAR',<xsl:value-of select="@length"/></xsl:for-each><xsl:for-each select="$MetadataTypeDefine//Money[@typename=$Name]">'DB_COLOUMN_TYPE_DOUBLE',NULL</xsl:for-each><xsl:for-each select="$MetadataTypeDefine//Price[@typename=$Name]">'DB_COLOUMN_TYPE_DOUBLE',NULL</xsl:for-each><xsl:for-each select="$MetadataTypeDefine//Ratio[@typename=$Name]">'DB_COLOUMN_TYPE_DOUBLE',NULL</xsl:for-each><xsl:for-each select="$MetadataTypeDefine//Long[@typename=$Name]">'DB_COLOUMN_TYPE_INT',NULL</xsl:for-each><xsl:for-each select="$MetadataTypeDefine//Enum[@typename=$Name]"> 'DB_COLOUMN_TYPE_CHAR',2</xsl:for-each><xsl:for-each select="$MetadataTypeDefine//Boolean[@typename=$Name]">'DB_COLOUMN_TYPE_CHAR',1</xsl:for-each>,'v8s',to_char(sysdate,'YYYYMMDD'),to_char(sysdate,'HH24:MI:SS'));
</xsl:for-each>
<xsl:for-each select="Response/Field">
<xsl:variable name="Name" select="@name"/>
insert into t_mc_function_detail(FunctionNo,FuncParaType,FuncParaIndex,FuncParaCode,FuncParaDataType,FuncParaDataLength,UpdateOperID,UpdateDate,UpdateTime)values
('<xsl:value-of select="$FuncNo"/>','1','<xsl:value-of select="position()"/>','<xsl:value-of select="$Name"/>',<xsl:for-each select="$MetadataTypeDefine//String[@typename=$Name]"> 'DB_COLOUMN_TYPE_CHAR',<xsl:value-of select="@length"/></xsl:for-each><xsl:for-each select="$MetadataTypeDefine//Money[@typename=$Name]">'DB_COLOUMN_TYPE_DOUBLE',NULL</xsl:for-each><xsl:for-each select="$MetadataTypeDefine//Price[@typename=$Name]">'DB_COLOUMN_TYPE_DOUBLE',NULL</xsl:for-each><xsl:for-each select="$MetadataTypeDefine//Ratio[@typename=$Name]">'DB_COLOUMN_TYPE_DOUBLE',NULL</xsl:for-each><xsl:for-each select="$MetadataTypeDefine//Long[@typename=$Name]">'DB_COLOUMN_TYPE_INT',NULL</xsl:for-each><xsl:for-each select="$MetadataTypeDefine//Enum[@typename=$Name]"> 'DB_COLOUMN_TYPE_CHAR',2</xsl:for-each><xsl:for-each select="$MetadataTypeDefine//Boolean[@typename=$Name]">'DB_COLOUMN_TYPE_CHAR',1</xsl:for-each>,'v8s',to_char(sysdate,'YYYYMMDD'),to_char(sysdate,'HH24:MI:SS'));
 </xsl:for-each>
 </xsl:for-each>
 commit;
</xsl:result-document>
	</xsl:template>  
</xsl:stylesheet>